import React from 'react';
import io from 'socket.io-client';
import { refreshView } from 'ra-core';
import { connect } from 'react-redux'
export const socket = io('http://localhost:8081');
class RealTime extends React.Component {
    
      componentDidMount(){
        const { dispatch } = this.props;
        socket.on('onDataChange',  rlt => {
            if(rlt===1){
                dispatch(refreshView());
            }
        });
      }
      render(){
          return (
              <React.Fragment>
                  {this.props.children}
              </React.Fragment>
          )
      }
}

export default connect()(RealTime);

